﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using BookSystem.Body;

namespace BookSystem
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
        }

        private void MainForm_FormClosed(object sender, FormClosedEventArgs e)
        {
            Application.Exit();
        }

        private void MainForm_Load(object sender, EventArgs e)
        {
            this.lab_Welcome.Text = string.Format("欢迎{0}！！来到{1}图书馆", Type.name, Type.lbrName);
            this.lab_Welcome.Show();

            if (Type.type == "管理员")
            {
                this.tsb_User.Visible = false;
            }
            else
            {
                this.tsb_Admin.Visible = false;
                this.tsb_Users.Visible = false;
                this.tsb_User.Margin = new System.Windows.Forms.Padding(21, 1, 37, 2);
            }
        }

        private void tsb_Admin_Click(object sender, EventArgs e)
        {
            AdminForm AdminForm = new AdminForm();
            AdminForm.ShowDialog();
        }

        private void tsb_Users_Click(object sender, EventArgs e)
        {
            SelectUsersForm SelectUsersForm = new SelectUsersForm();
            SelectUsersForm.ShowDialog();
        }

        private void tsb_User_Click(object sender, EventArgs e)
        {
            UsersForm UsersForm = new UsersForm();
            UsersForm.ShowDialog();
        }

        private void tsb_Books_Click(object sender, EventArgs e)
        {
            if (Type.type == "管理员")
            {
                BooksForm BooksForm = new BooksForm();
                BooksForm.ShowDialog();
            }
            else
            {
                SelectBooksForm SelectBooksForm = new SelectBooksForm();
                SelectBooksForm.ShowDialog();
            }
        }

        private void tsb_SelectBorrow_Click(object sender, EventArgs e)
        {
            if (Type.type == "管理员")
            {
                SumSelectForm SumSelectForm = new SumSelectForm();
                SumSelectForm.ShowDialog();
            }
            else
            {
                SelectBorrowBookForm SelectBorrowBookForm = new SelectBorrowBookForm();
                SelectBorrowBookForm.ShowDialog();
            }
        }

        private void tsb_Leave_Click(object sender, EventArgs e)
        {
            MessageBox.Show("您确定要退出该系统嘛?", "退出提示:",
                MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
        }
    }
}
